package com.cx.android;

import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.app.PendingIntent;
import android.widget.RemoteViews;
import android.graphics.Bitmap; 
import android.util.Log;

public class Code1009AppWidgetProvider extends AppWidgetProvider 
{	
	@Override   
	public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)         
	{                 
		super.onUpdate(context, appWidgetManager, appWidgetIds);                 
		context.startService(Code1009Intents.refreshWidgets(context));         
	} 

	public static void UpdateWidget(Context context, AppWidgetManager widgetManager, int widgetId /*, final Code1009AppWidgetUpdateInfo info*/)         
	{ 		
		 Intent        activityintent = new Intent(context, Code1009Activity.class);
		 //PendingIntent pendingIntent  = PendingIntent.getActivity(context, 0, activityintent, 0);		 
		 
		 
		 Code1009ImageFactory cif = new Code1009ImageFactory(context); 
		 Bitmap bitmap = cif.getBitmap ();
		
		final Intent      intent = new Intent(context, Code1009IntentService.class);                 
		final RemoteViews views  = new RemoteViews(context.getPackageName(), R.layout.lo_appwidget);
		
		views.setRemoteAdapter(R.id.imageView1, intent);
		
		//Code1009Intents.BindClickActionActivity(context, views, R.id.imageView1, widgetId, activityintent);
		Code1009Intents.BindClickAction(context, views, R.id.imageView1, widgetId,  Code1009Intents.refreshWidgets(context));
		
		views.setImageViewBitmap (R.id.imageView1, bitmap);
		 
		widgetManager.updateAppWidget(widgetId, views);
	}
}
